package Clone;

import Clone.create.ObjectCreator;
import Clone.model.Model2;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;

/**
 * Created by wangyg 
 * on 2017/3/23 21:13
 */
public class TestDepthClone {
	public static void main(String[] args) throws IOException, ClassNotFoundException {
		ObjectCreator o = new ObjectCreator();
		Model2 obj = o.createObj();
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		ObjectOutputStream oos = new ObjectOutputStream(bos);
		oos.writeObject(obj);
		ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
		ObjectInputStream ois = new ObjectInputStream(bis);
		Object o1 = ois.readObject();
		System.out.println(obj.toString());
		System.out.println(o1.toString());
		if (o1 == obj)
			System.out.println("同一个");
		if (obj.equals(o1))
			System.out.println("相等不相同");
	}

}

